### Project 15 Knock Module This is a knock sensor module. When you knock it, it can send a momentary signal. You can combine it with Arduino to make some interesting experiment, e.g. electronic drum. - Working voltage: 5V ![](media/image-20251121102257786.png) **1. Connection Diagram** ![](media/image-20251121102436511.png) **2. Sample Code** ```c int Led=13;//define LED interface int Shock=3;//define knock sensor interface int val;//define digital variable val void setup() { pinMode(Led,OUTPUT);//define LED to be output interface pinMode(Shock,INPUT);//define knock sensor to be output interface } void loop() { val=digitalRead(Shock);//read the value of interface3 and evaluate it to val if(val==HIGH)//when the knock sensor detect a signal, LED will be flashing { digitalWrite(Led,LOW); } else { digitalWrite(Led,HIGH); } } ``` **3. Result** Upload the code to the board. When the sensor detects a knock signal, both the led on the sensor and led 13 on the UNO board are turned on. **4. Extension** You can extend to connect an external LED; when knock the sensor, the external LED will turn on. For example: ![](media/image-20251121102609274.png)